#ifndef CLNT_CONNECTION_H
#define CLNT_CONNECTION_H

#include <unistd.h>
#include <stdio.h>
#include <pthread.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include "protocol.h"
#include "coder.h"

#define OK 1
#define NO 0
#define SUCCESS 1
#define FAIL 0
#define FAIL_NO_ID  0
#define FAIL_WRONG_PASSWORD 1
#define BUF_SIZE 128
#define USER_BUF_SIZE 17
#define APP_NAME_SIZE 256
#define FILE_NAME_SIZE APP_NAME_SIZE
#define APP_PATH_SIZE 512
#define ID_ANSWER_SIZE 5
#define ICON_PATH_SIZE 100

int readn(int fd, void *vptr, int n);
void* clnt_connection(void *arg);
void ClientIdCheck(int clnt_sock, char* message);
void ClientJoin(int clnt_sock, char* message);
void ClientLogin(int clnt_sock, char* message);
void RequestProgramList(int clnt_sock);
void AppProgramList(int clnt_sock, char* message);
void AppIconImage(int clnt_sock, char* message);
void AppServerStop(int clnt_sock);

typedef struct user{

	char id[USER_BUF_SIZE];
	char password[USER_BUF_SIZE];
	char result;
	char fail_reason;

}USER;

typedef struct app{

	char name[APP_NAME_SIZE];
	char apppath[APP_PATH_SIZE];

}APP;



#endif
